package com.litidea.dataobjects;

import java.util.ArrayList;
import java.util.List;

public class MenuNodeDO {

    private static String ICON_URL;
    
    public static void init(String contextPath) {
    	ICON_URL = contextPath + "/share/images/extend/leaf.png";
    }

    /**
     * ID编号
     */
    protected Integer id;

    /**
     * 对应name值
     */
    protected String text;

    /**
     * 父节点ID
     */
    protected Integer parentId;

    /**
     * 层次
     */
    protected Integer levelId;

    /**
     * 所有父亲ID，包含本身，使用{}作为分解符号
     */
    protected String allParentId;

    /**
     * 获取菜单的描述
     */
    protected String menuDesc;

    /**
     * 触发事件方法，1：调用方法；2：页面链接 其他值代表什么都不做
     */
    protected Integer clickType;

    /**
     * 如果是页面链接，这里展现URL
     */
    protected String url;

    /**
     * 如果是目标路径，则设定为default或_blank
     */
    protected String target;

    /**
     * 如果是调用方法，则为方法名称
     */
    private String functionName;

    /**
     * 对象ID，用于重复判定对象存在，以切换时使用
     */
    private String objectId;

    /**
     * 复用控件，如果控件被复用，则在调用时，需要传入业务关键字
     */
    private Integer isMutiObject;

    /**
     * 是否刷新，即通过菜单切换选项卡时，是否需要调用refresh方法，各自提供一个refresh()方法
     */
    private Integer isRefresh;

    /**
     * js文件列表，多个文件用逗号分隔
     */
    private String jsFiles;

    /**
     * 跳转关键字，用于通过URL可以直接访问到某个菜单
     */
    private String locationKey;

    /**
     * 排序编号，默认在SQL中使用，在维护时需要使用到。
     */
    protected Integer orderId;

    /**
     * 业务编码
     */
    private String busiKey;

    /**
     * 子系统名称，只有一级菜单有效
     */
    private String sysName;

    /**
     * 菜单类型，1：均可见；0：需要授权才可以
     */
    private Integer menuType;

    private Integer canDel;

    protected List<MenuNodeDO> children;
    
    private String profCode;

    private Integer expandChild;

    public String getProfCode() {
		return profCode;
	}

	public void setProfCode(String profCode) {
		this.profCode = profCode;
	}

	public List<MenuNodeDO> getChildren() {
        return children;
    }

    public void setChildren(List<MenuNodeDO> children) {
        this.children = children;
    }

    public Integer getCanDel() {
        return canDel;
    }

    public void setCanDel(Integer canDel) {
        this.canDel = canDel;
    }

    public void addChild(MenuNodeDO child) {
        if(this.children == null) this.children = new ArrayList<MenuNodeDO>();
        this.children.add(child);
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Integer getParentId() {
    	if(parentId == null || parentId == 0) return null;
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getLevelId() {
        return levelId;
    }

    public void setLevelId(Integer levelId) {
        this.levelId = levelId;
    }

    public String getAllParentId() {
        return allParentId;
    }

    public void setAllParentId(String allParentId) {
        this.allParentId = allParentId;
    }

    public String getMenuDesc() {
        return menuDesc;
    }

    public void setMenuDesc(String menuDesc) {
        this.menuDesc = menuDesc;
    }

    public Integer getClickType() {
        return clickType;
    }

    public void setClickType(Integer clickType) {
        this.clickType = clickType;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }

    public String getObjectId() {
        return objectId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    public Integer getMutiObject() {
        return isMutiObject;
    }

    public void setMutiObject(Integer mutiObject) {
        isMutiObject = mutiObject;
    }

    public Integer getRefresh() {
        return isRefresh;
    }

    public void setRefresh(Integer refresh) {
        isRefresh = refresh;
    }

    public String getJsFiles() {
        return jsFiles;
    }

    public void setJsFiles(String jsFiles) {
        this.jsFiles = jsFiles;
    }

    public String getLocationKey() {
        return locationKey;
    }

    public void setLocationKey(String locationKey) {
        this.locationKey = locationKey;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public String getBusiKey() {
        return busiKey;
    }

    public void setBusiKey(String busiKey) {
        this.busiKey = busiKey;
    }

    public Integer getMenuType() {
        return menuType;
    }

    public void setMenuType(Integer menuType) {
        this.menuType = menuType;
    }

    public Boolean getLeaf() {
        return this.children == null || this.children.isEmpty();
    }

    public String getIcon() {
        if(getLeaf()) return ICON_URL;
        return null;
    }

    public Integer getExpandChild() {
        return expandChild;
    }

    public void setExpandChild(Integer expandChild) {
        this.expandChild = expandChild;
    }

    public String getSysName() {
        return sysName;
    }

    public void setSysName(String sysName) {
        this.sysName = sysName;
    }
}
